﻿using System;
using System.ComponentModel;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a Deep Neural Network inference step result.</summary>
	// Token: 0x02000033 RID: 51
	public class HDlClassifierResult : HHandle
	{
		// Token: 0x060004AB RID: 1195 RVA: 0x0000883B File Offset: 0x00006A3B
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HDlClassifierResult() : base(HHandleBase.UNDEF)
		{
		}

		// Token: 0x060004AC RID: 1196 RVA: 0x0001BEA4 File Offset: 0x0001A0A4
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HDlClassifierResult(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x060004AD RID: 1197 RVA: 0x0001BEB3 File Offset: 0x0001A0B3
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HDlClassifierResult(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x060004AE RID: 1198 RVA: 0x0001BEC2 File Offset: 0x0001A0C2
		private void AssertSemType()
		{
			base.AssertSemType("dl_classifier_result");
		}

		// Token: 0x060004AF RID: 1199 RVA: 0x0001BECF File Offset: 0x0001A0CF
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HDlClassifierResult obj)
		{
			obj = new HDlClassifierResult(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x060004B0 RID: 1200 RVA: 0x0001BEE8 File Offset: 0x0001A0E8
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HDlClassifierResult[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HDlClassifierResult[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HDlClassifierResult(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Infer the class affiliations for a set of images using a  deep-learning-based classifier.
		///   Modified instance represents: Handle of the deep learning classification  results.
		/// </summary>
		/// <param name="images">Tuple of input images.</param>
		/// <param name="DLClassifierHandle">Handle of the deep-learning-based classifier.</param>
		// Token: 0x060004B1 RID: 1201 RVA: 0x0001BF58 File Offset: 0x0001A158
		public HDlClassifierResult(HImage images, HDlClassifier DLClassifierHandle)
		{
			IntPtr proc = HalconAPI.PreCall(2102);
			HalconAPI.Store(proc, 1, images);
			HalconAPI.Store(proc, 0, DLClassifierHandle);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(images);
			GC.KeepAlive(DLClassifierHandle);
		}

		/// <summary>Clear a handle containing the results of the deep-learning-based classification.</summary>
		/// <param name="DLClassifierResultHandle">Handle of the deep learning classification  results.</param>
		// Token: 0x060004B2 RID: 1202 RVA: 0x0001BFB8 File Offset: 0x0001A1B8
		public static void ClearDlClassifierResult(HDlClassifierResult[] DLClassifierResultHandle)
		{
			HTuple htuple = HHandleBase.ConcatArray(DLClassifierResultHandle);
			IntPtr proc = HalconAPI.PreCall(2104);
			HalconAPI.Store(proc, 0, htuple);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(htuple);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(DLClassifierResultHandle);
		}

		/// <summary>
		///   Clear a handle containing the results of the deep-learning-based classification.
		///   Instance represents: Handle of the deep learning classification  results.
		/// </summary>
		// Token: 0x060004B3 RID: 1203 RVA: 0x0001BFFC File Offset: 0x0001A1FC
		public void ClearDlClassifierResult()
		{
			IntPtr proc = HalconAPI.PreCall(2104);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Retrieve classification results inferred by a deep-learning-based  classifier.
		///   Instance represents: Handle of the deep learning classification  results.
		/// </summary>
		/// <param name="index">Index of the image in the batch. Default: "all"</param>
		/// <param name="genResultName">Name of the generic parameter. Default: "predicted_classes"</param>
		/// <returns>Value of the generic parameter, either the confidence  values, the class names or class indices.</returns>
		// Token: 0x060004B4 RID: 1204 RVA: 0x0001C030 File Offset: 0x0001A230
		public HTuple GetDlClassifierResult(HTuple index, HTuple genResultName)
		{
			IntPtr proc = HalconAPI.PreCall(2115);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, index);
			HalconAPI.Store(proc, 2, genResultName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(index);
			HalconAPI.UnpinTuple(genResultName);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Retrieve classification results inferred by a deep-learning-based  classifier.
		///   Instance represents: Handle of the deep learning classification  results.
		/// </summary>
		/// <param name="index">Index of the image in the batch. Default: "all"</param>
		/// <param name="genResultName">Name of the generic parameter. Default: "predicted_classes"</param>
		/// <returns>Value of the generic parameter, either the confidence  values, the class names or class indices.</returns>
		// Token: 0x060004B5 RID: 1205 RVA: 0x0001C094 File Offset: 0x0001A294
		public HTuple GetDlClassifierResult(string index, string genResultName)
		{
			IntPtr proc = HalconAPI.PreCall(2115);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, index);
			HalconAPI.StoreS(proc, 2, genResultName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}
	}
}
